/*
 * Protocolo_NIPC.h
 *
 *  Created on: 22/10/2011
 *      Author: utn_so
 */

#ifndef PROTOCOLO_NIPC_H_
#define PROTOCOLO_NIPC_H_

#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include "PPD.h"
#include "CHS.h"

extern tipoConfigPPD configuracion;

typedef struct paquete{
	uint8_t type;
	uint16_t payload_Length;
	uint32_t nro_Sector;
	char payload[512];
}__attribute__((packed)) paquete;



typedef paquete *paqueteNIPC;

int32_t conectarse_RAID(char* DIRECCION_IP,uint16_t PUERTO,char* IDENTIFICADOR_DISCO);
int32_t conectarse_FS(char* DIRECCION_IP,uint16_t PUERTO,char* IDENTIFICADOR_DISCO);
int32_t handshakePPD(int32_t socket, char* identificador_disco);
int32_t handshakePRAID_PPD(int32_t socket, paquete *NIPC);
int32_t handshakeFS_PPD(int32_t socket, int32_t type);
void enviarSector(t_sector sector);
t_sector recibirSector(int32_t socket);

#endif /* PROTOCOLO_NIPC_H_ */
